home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / machine / exterm.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  3KB  |  139 lines

  1. #include "driver.h"
  2. #include "cpu/tms34010/tms34010.h"
  3.  
  4. extern unsigned char *exterm_code_rom;
  5. unsigned char *exterm_master_speedup, *exterm_slave_speedup;
  6.  
  7. static int aimpos1, aimpos2;
  8.  
  9.  
  10. WRITE_HANDLER( exterm_host_data_w )
  11. {
  12.     tms34010_host_w(1, offset / TOBYTE(0x00100000), data);
  13. }
  14.  
  15.  
  16. READ_HANDLER( exterm_host_data_r )
  17. {
  18.     return tms34010_host_r(1, TMS34010_HOST_DATA);
  19. }
  20.  
  21.  
  22. READ_HANDLER( exterm_coderom_r )
  23. {
  24.     return READ_WORD(&exterm_code_rom[offset]);
  25. }
  26.  
  27.  
  28. READ_HANDLER( exterm_input_port_0_1_r )
  29. {
  30.     int hi = input_port_1_r(offset);
  31.     if (!(hi & 2)) aimpos1++;
  32.     if (!(hi & 1)) aimpos1--;
  33.     aimpos1 &= 0x3f;
  34.  
  35.     return ((hi & 0x80) << 8) | (aimpos1 << 8) | input_port_0_r(offset);
  36. }
  37.  
  38. READ_HANDLER( exterm_input_port_2_3_r )
  39. {
  40.     int hi = input_port_3_r(offset);
  41.     if (!(hi & 2)) aimpos2++;
  42.     if (!(hi & 1)) aimpos2--;
  43.     aimpos2 &= 0x3f;
  44.  
  45.     return (aimpos2 << 8) | input_port_2_r(offset);
  46. }
  47.  
  48. WRITE_HANDLER( exterm_output_port_0_w )
  49. {
  50.     /* All the outputs are activated on the rising edge */
  51.  
  52.     static int last = 0;
  53.  
  54.     /* Bit 0-1= Resets analog controls */
  55.     if ((data & 0x0001) && !(last & 0x0001))
  56.     {
  57.         aimpos1 = 0;
  58.     }
  59.  
  60.     if ((data & 0x0002) && !(last & 0x0002))
  61.     {
  62.         aimpos2 = 0;
  63.     }
  64.  
  65.     /* Bit 13 = Resets the slave CPU */
  66.     if ((data & 0x2000) && !(last & 0x2000))
  67.     {
  68.         cpu_set_reset_line(1,PULSE_LINE);
  69.     }
  70.  
  71.     /* Bits 14-15 = Coin counters */
  72.     coin_counter_w(0, data & 0x8000);
  73.     coin_counter_w(1, data & 0x4000);
  74.  
  75.     last = data;
  76. }
  77.  
  78.  
  79. READ_HANDLER( exterm_master_speedup_r )
  80. {
  81.     int value = READ_WORD(&exterm_master_speedup[offset]);
  82.  
  83.     /* Suspend cpu if it's waiting for an interrupt */
  84.     if (cpu_get_pc() == 0xfff4d9b0 && !value)
  85.     {
  86.         cpu_spinuntil_int();
  87.     }
  88.  
  89.     return value;
  90. }
  91.  
  92. WRITE_HANDLER( exterm_slave_speedup_w )
  93. {
  94.     /* Suspend cpu if it's waiting for an interrupt */
  95.     if (cpu_get_pc() == 0xfffff050)
  96.     {
  97.         cpu_spinuntil_int();
  98.     }
  99.  
  100.     WRITE_WORD(&exterm_slave_speedup[offset], data);
  101. }
  102.  
  103. READ_HANDLER( exterm_sound_dac_speedup_r )
  104. {
  105.     unsigned char *RAM = memory_region(REGION_CPU3);
  106.     int value = RAM[0x0007];
  107.  
  108.     /* Suspend cpu if it's waiting for an interrupt */
  109.     if (cpu_get_pc() == 0x8e79 && !value)
  110.     {
  111.         cpu_spinuntil_int();
  112.     }
  113.  
  114.     return value;
  115. }
  116.  
  117. READ_HANDLER( exterm_sound_ym2151_speedup_r )
  118. {
  119.     /* Doing this won't flash the LED, but we're not emulating that anyhow, so
  120.        it doesn't matter */
  121.  
  122.     unsigned char *RAM = memory_region(REGION_CPU4);
  123.     int value = RAM[0x02b6];
  124.  
  125.     /* Suspend cpu if it's waiting for an interrupt */
  126.     if (  cpu_get_pc() == 0x8179 &&
  127.         !(value & 0x80) &&
  128.           RAM[0x00bc] == RAM[0x00bb] &&
  129.           RAM[0x0092] == 0x00 &&
  130.           RAM[0x0093] == 0x00 &&
  131.         !(RAM[0x0004] & 0x80))
  132.     {
  133.         cpu_spinuntil_int();
  134.     }
  135.  
  136.     return value;
  137. }
  138.  
  139.